<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>外间距测试</title>
    <style>
        body{
            margin: 0;
        }
        .fu{
            background-color: rgba(255,255,0,.3);
            overflow: hidden;/*让父元素形成结界*/
        }
        .fu div{
            width: 100px;
            height: 100px;
            background-color: rgba(0,0,255,.6);
            border: 2px solid #00f;
            color: #fff;

        }
        .z1{
            margin-bottom: 20px;
            margin-top: 50px;/*第一个子元素的上外间距会超出父元素的范围*/

        }
        .z2{
            margin-top: 50px;/*兄弟间在垂直方向上的外间距,取最大值显示*/
        }
        .z3{
            margin:0 auto;
        }
        .z4{
            margin-bottom: 50px;/*最后一个子元素的下外间距会超出父元素的范围*/
        }
        .s2{
            margin: 20px;

            display: inline-block;
        }
    </style>

</head>
<body>
    <span>span1</span>
    <span class="s2">span2</span>
    <span>span3</span>
<!--    .fu>.z*4-->
    <div class="fu">
        <div class="z1">子元素div1</div>
        <div class="z2">子元素div2</div>
        <div class="z3">子元素div3</div>
        <div class="z4">子元素div4</div>
    </div>
</body>
</html>